package service

import (
	"fmt"
	"hotMoney/controller"
	"hotMoney/data"
	"hotMoney/model"
)




func InitRewardToDb(totalAmount, count, leftCount int)(err error) {
	reward := &model.Reward{
		TotalAmount: totalAmount,
		Count: count,
		LeftCount: leftCount,
	}
	err = data.Db.Create(reward).Error
	return err
}


func InitRewardInfoToDb(id, money int)(err error) {
	rewardInfo := &model.RewardInfo{
		AmountID: id,
		Amount: money,
	}
	err = data.Db.Create(&rewardInfo).Error
	return err
}


func UpdateUserAmountInfo(){
	for {
		usr:= <-controller.Userchan
		user := &model.User{
			Username: usr.Username,
			Amount: usr.Amount,
		}
		err := data.Db.Create(&user).Error
		fmt.Println(err)
	}


}